package ar.edu.unq.wannaplay.panels.employee;

import java.util.LinkedList;

import ar.edu.unq.wannaplay.dtos.SkillDTO;
import ar.edu.unq.wannaplay.exceptions.EmailSyntaxException;
import ar.edu.unq.wannaplay.pages.employee.EmployeesViewPage;
import ar.edu.unq.wannaplay.panels.FeedBackPanel;
import ar.edu.unq.wannaplay.services.EmployeeService;
import ar.edu.unq.wannaplay.utils.EmployeeEditer;

public class NewEmployeePanel extends EditEmployeePanel {

    public NewEmployeePanel(final String id, final EmployeeEditer modelObject, final EmployeeService service,
            final FeedBackPanel panel) {
        super(id, modelObject, service, panel);
    }

    @Override
    protected String[] getFieldsStrings() {
        return new String[] { "dni", "name", "surname", "email", "address", "town", "university" };
    }

    @Override
    protected void addComponents() {
        // no hay componentes extras
    }

    private static final long serialVersionUID = 1L;

    @Override
    protected void acceptAction() {
        try {
            this.getService().saveEmployee(this.getModelObject().personalData(), "", new LinkedList<SkillDTO>());
        } catch (EmailSyntaxException e) {
            this.getFeedBackPanel().changeMessage(this.getLocalizer().getString("client.error.emailSyntax", this));
        }
        this.setResponsePage(EmployeesViewPage.class);

    }
}
